<template>
  <div class="allOrderContainer">
    <div class="content-wrapper">
      <!-- 运单搜索 -->
      <!-- <WaybillSearchHead
        ref="WaybillSearchHead"
        v-if="tabIndex === '3'"
        @search="handleReceiptSearch"
        @reset="handleReceiptReset"
      >
      </WaybillSearchHead> -->
      <!-- <div
        class="orderHeader"
        :key="tabIndex"
        style="margin: 5px 0px 0px 0px"
        v-else
      >
        <div class="orderSearch">
          <el-form ref="form" :model="searchParams" :inline="true">
            <el-form-item label="回单批次">
              <el-input
                v-model="searchParams.batch_number"
                clearable
                placeholder="请填写回单批次进行搜索"
              />
            </el-form-item>
            <el-form-item label="运单号">
              <el-input
                  id="waybill_no_search"
                v-model="searchParams.waybill_no"
                placeholder="支持批量搜索,多个单号用逗号分隔"
                clearable
              />
            </el-form-item>
            <el-form-item label="发件网点">
              <el-cascader
                v-model="searchParams.from_network_id"
                :options="organizationBoxData"
                :props="propsBranchType"
                :show-all-levels="false"
                filterable
                clearable
              >
              </el-cascader>
            </el-form-item>
            <el-form-item label="发件人">
              <el-input
                v-model="searchParams.sender_name"
                type="text"
                clearable
                placeholder="请输入发件人"
              />
            </el-form-item>
            <el-form-item label="收件网点">
              <el-cascader
                v-model="searchParams.to_network_id"
                :options="organizationBoxData"
                :props="propsBranchType"
                :show-all-levels="false"
                filterable
                clearable
              >
              </el-cascader>
            </el-form-item>
            <el-form-item label="收件人">
              <el-input
                v-model="searchParams.receiver_name"
                placeholder="请输入收件人"
                clearable
              />
            </el-form-item>
            <el-form-item label="快递公司">
              <el-input
                v-model="searchParams.express_name"
                type="text"
                placeholder="请输入快递公司"
                clearable
              />
            </el-form-item>
            <el-form-item label="快递单号">
              <el-input
                v-model="searchParams.express_no"
                type="text"
                placeholder="请输入快递单号"
                clearable
              />
            </el-form-item>
            <el-form-item size="mini">
              <el-button
                  id="go_search"
                type="primary"
                icon="el-icon-search"
                @click="handleSearch"
                data-tracker="P11-1"
                >查询</el-button
              >
              <el-button
                type="primary"
                plain
                icon="el-icon-refresh"
                @click="handleReset"
                data-tracker="P11-2"
                >重置
              </el-button>
            </el-form-item>
          </el-form>
        </div>
      </div> -->
      <div class="content">
        <div class="actions" style="margin-bottom: 10px">
          <div class="left" :key="tabIndex">
            <!-- <el-button style="margin-right: 10px" type="primary" plain size="mini" @click="clickEditPropFn">回单回收</el-button> -->
            <el-button
              id="receipt_create_button"
              data-tracker="P11-3"
              type="primary"
              plain
              size="mini"
              @click="clickAddPropFn"
              v-if="tabIndex === '3'"
              v-permission="'waybill_receipt_create'"
              >创建回单</el-button
            >
            <el-button
              id="receipt_cancel_button"
              type="primary"
              plain
              size="mini"
              @click="() => handleClickOper('DELETE')"
              v-else-if="tabIndex === '0'"
              data-tracker="P11-12"
              v-permission="'waybill_receipt_delete'"
              >取消回单
            </el-button>
            <el-button
              id="receipt_sign_button"
              type="primary"
              plain
              size="mini"
              @click="() => handleClickOper('FINISH')"
              v-else-if="tabIndex === '1'"
              data-tracker="P11-8"
              v-permission="'waybill_receipt_receipt_sign'"
              >签收</el-button
            >
            <el-button
              id="receipt_cancel_sign_button"
              type="primary"
              plain
              size="mini"
              v-else-if="tabIndex === '2'"
              @click="() => handleClickOper('CANCEL')"
              data-tracker="P11-9"
              v-permission="'waybill_receipt_receipt_sign_cancel'"
              >取消签收</el-button
            >
            <el-dropdown
              v-permission="'waybillReceipt_import_update'"
              @command="handleWaybillMessage"
              divided
              class="operation-drop"
            >
              <el-button type="primary" plain>
                导入<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu
                class="operation-drop"
                slot="dropdown"
                style="width: 150px"
              >
                <el-dropdown-item command="4">修改回单信息</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
            <el-button
              type="primary"
              :key="tabIndex"
              :loading="isLoading"
              plain
              size="mini"
              @click="handleExport('0')"
              v-permission="
                tabIndex === '3'
                  ? 'waybillReceipt_stay_export'
                  : 'waybillReceipt_export'
              "
              >导出</el-button
            >
          </div>
          <div class="right" style="display: flex">
            <!-- <el-pagination
              small
              :current-page="paginations.pageIndex"
              :page-sizes="paginations.pageSizes"
              :page-size="paginations.pageSize"
              :layout="paginations.layout"
              :total="paginations.total"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            /> -->
            <el-button
              type="primary"
              icon="el-icon-refresh"
              @click="handleReset"
              data-tracker="P11-2"
              style="margin-right: 10px"
              >重置
            </el-button>
            <div v-if="tabIndex === '3'">
              <SettinUp
                :settype="1"
                :objSettinUpdata="objSettinUp"
                key="2"
              ></SettinUp>
            </div>
            <!-- <div v-else-if="tabIndex === '0'">
              <SettinUp :settype="4" :objSettinUpdata="objSettinUp" key="4"></SettinUp>
            </div> -->
            <div v-else>
              <SettinUp
                :settype="4"
                :objSettinUpdata="objSettinUp"
                key="3"
              ></SettinUp>
            </div>
          </div>
        </div>
        <div v-if="tabIndex === '3' && header_data_list.length > 0">
          <TableHeader
            ref="TableHeaderList"
            :header_data_list="header_data_list"
            :HeaderData="HeaderData"
            :propMap="propMap"
            :objheader="objheader"
            @childEvent="handleDelete"
            @orderIdNumsEvent="handleDeleteType"
          ></TableHeader>
        </div>
        <div v-else>
          <TableHeader
            v-if="header_data_list_two.length > 0"
            ref="TableHeaderList"
            :header_data_list="header_data_list_two"
            :HeaderData="HeaderData_two"
            :propMap="propMap_two"
            :objheader="objheader_two"
            @childEvent="handleDelete_two"
            @orderIdNumsEvent="handleDeleteType_two"
            :operation_type="operation_type"
            @handleClickDetail_three="handleClickDetail_three"
            @handleClickEdit_three="handleClickEdit_three"
            @clickabnormalFn_three="clickabnormalFn_three"
            @childEventJupway="handleJumpway"
            particulars="waybill_receipt_detail_waybill_id"
            redact="waybill_receipt_update"
            modification="abnormal_record_create"
          ></TableHeader>
        </div>
        <div
          style="
            display: flex;
            justify-content: flex-end;
            margin: 10px 0px 0px 0px;
          "
        >
          <el-pagination
            small
            background
            :current-page="paginations.pageIndex"
            :page-sizes="paginations.pageSizes"
            :page-size="paginations.pageSize"
            :layout="paginations.layout"
            :total="paginations.total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
        <!-- <el-table
            id="filter_box"
          ref="multipleTable"
          :row-key="(item) => item.id"
          :data="orders"
          border
          stripe
          align="center"
          @selection-change="handleSelectionChange"
          style="width: 100%"
          v-if="tabIndex === '3'"
          key="3"
        >
          <el-table-column
            type="selection"
            width="45"
            :reserve-selection="true"
          >
          </el-table-column>
          <el-table-column
            prop=""
            fixed
            label="序号"
            width="50"
            type="index"
          ></el-table-column>
          <el-table-column prop="waybill_no" fixed label="运单号" width="180">
            <template slot-scope="scope">
              <span
                style="cursor: pointer; color: blue"
                @click="handleJump(scope.row.id)"
                >{{ scope.row.waybill_no }}
              </span>
            </template>
          </el-table-column>
          <el-table-column prop="receiver_company" label="收货公司" width="180">
          </el-table-column>
          <el-table-column prop="receiver_name" label="收货人" width="180">
          </el-table-column>
          <el-table-column
            prop="receiver_phone"
            label="收货人手机号"
            width="180"
          >
          </el-table-column>
          <el-table-column prop="receiver_address" label="收货地址" width="260">
          </el-table-column>
          <el-table-column
            prop="waybill_product_type_name"
            label="承运类型"
            width="120"
          >
          </el-table-column>
          <el-table-column prop="status" label="运单状态" width="100">
            <template slot-scope="scope">
              {{ statusArr[scope.row.status] }}
            </template>
          </el-table-column>
          <el-table-column prop="from_area_name" label="出发区域" width="180">
          </el-table-column>
          <el-table-column prop="to_area_name" label="目的区域" width="180">
          </el-table-column>
          <el-table-column
            prop="from_network_name"
            label="出发网点"
            width="180"
          >
          </el-table-column>
          <el-table-column prop="to_network_name" label="目的网点" width="180">
          </el-table-column>
          <el-table-column prop="sender_company" label="发货公司" width="180">
          </el-table-column>
          <el-table-column prop="sender_name" label="发货人" width="180">
          </el-table-column>
          <el-table-column prop="sender_phone" label="发货人手机号" width="180">
          </el-table-column>
          <el-table-column prop="sender_address" label="发货地址" width="260">
          </el-table-column>

          <el-table-column prop="create_time" label="创建时间" width="180">
            <template slot-scope="scope">
              <span v-time="scope.row.create_time"></span>
            </template>
          </el-table-column>
          <el-table-column prop="total_goods_cnt" label="总件数" width="80">
          </el-table-column>
          <el-table-column prop="thermosphere_name" label="温层" width="140">
          </el-table-column>
          <el-table-column prop="from_region_name" label="发站" width="180">
          </el-table-column>
          <el-table-column prop="to_region_name" label="到站" width="100">
          </el-table-column>
          <el-table-column prop="router" label="路由" width="180">
          </el-table-column>
          <el-table-column prop="handler_name" label="经办人" width="100">
          </el-table-column>
          <el-table-column prop="total_freight" label="总运费" width="100">
          </el-table-column>
          <el-table-column prop="receipt_count" label="客户回单" width="80">
            <template slot-scope="scope">
              {{
                scope.row.receipt_count === "1" ||
                scope.row.receipt_count === "3"
                  ? "是"
                  : "否"
              }}
            </template>
          </el-table-column>
          <el-table-column prop="receipt_count" label="我司回单" width="80">
            <template slot-scope="scope">
              {{
                scope.row.receipt_count === "2" ||
                scope.row.receipt_count === "3"
                  ? "是"
                  : "否"
              }}
            </template>
          </el-table-column>
          <el-table-column prop="remark" label="备注" width="180">
          </el-table-column>
          <el-table-column prop="last_editor_name" label="操作人" width="100">
          </el-table-column>
          <el-table-column prop="customer_id_name" label="所属客户" width="100">
          </el-table-column>

          <el-table-column
            prop="customer_area_name"
            label="客户所属大区"
            show-overflow-tooltip
            width="120"
          >
          </el-table-column>
          <el-table-column prop="sign_time" label="签收时间" width="180">
            <template slot-scope="scope">
              <span v-time="scope.row.sign_time"></span>
            </template>
          </el-table-column>
          <el-table-column prop="update_time" label="操作时间" width="180">
            <template slot-scope="scope">
              <span v-time="scope.row.update_time"></span>
            </template>
          </el-table-column>
        </el-table> -->
        <!-- <el-table
            id="filter_box_2"
          ref="multipleTable"
          :data="receiptList"
          border
          stripe
          align="center"
          @selection-change="handleSelectionChange"
          style="width: 100%"
          v-else
          :key="tabIndex"
        >
          <el-table-column type="selection" width="45"> </el-table-column>
          <el-table-column prop="" type="index" fixed label="序号" width="50">
          </el-table-column>
          <el-table-column
            property="batch_number"
            label="回单批次"
            width="180"
          ></el-table-column>
          <el-table-column property="waybill_number" label="运单号" width="180">
            <template slot-scope="scope">
              <span
                style="cursor: pointer; color: blue"
                @click="handleJump(scope.row.waybill_id)"
                >{{ scope.row.waybill_number }}
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="status"
            label="回单状态"
            width="80"
            v-if="tabIndex === '0'"
          >
            <template slot-scope="scope">
              <span>{{ ["未签收", "已签收"][scope.row.status] }}</span>
            </template>
          </el-table-column>
          <el-table-column
            property="from_network_name"
            label="发件网点"
            width="180"
          ></el-table-column>
          <el-table-column
            property="sender_name"
            label="发件人"
            width="180"
          ></el-table-column>

          <el-table-column
            property="to_network_name"
            label="收件网点"
            width="180"
          ></el-table-column>
          <el-table-column
            property="receiver_name"
            label="收件人"
            width="180"
          ></el-table-column>

          <el-table-column
            v-if="tabIndex === '2'"
            prop="sign_time"
            label="签收时间"
            width="180"
          >
            <template slot-scope="scope">
              <span v-time="scope.row.sign_time"></span>
            </template>
          </el-table-column>
          <el-table-column property="carrier_type" label="运输类型" width="180">
            <template slot-scope="scope">
              {{ ["自营", "委外"][scope.row.carrier_type] }}
            </template>
          </el-table-column>
          <el-table-column
            property="express_name"
            label="快递公司"
            width="180"
          ></el-table-column>
          <el-table-column
            property="express_no"
            label="快递单号"
            width="180"
          ></el-table-column>
          <el-table-column
            v-if="!tabIndex === '2'"
            property="expense"
            label="回单费用"
            width="180"
          ></el-table-column>
          <el-table-column prop="last_editor_name" label="操作人" width="180">
          </el-table-column>
          <el-table-column prop="create_time" label="创建回单时间" width="180"   v-if="tabIndex === '1'">
            <template slot-scope="scope">
              <span v-time="scope.row.create_time"></span>
            </template>
          </el-table-column>

          <el-table-column prop="update_time" label="操作时间" width="180">
            <template slot-scope="scope">
              <span v-time="scope.row.update_time"></span>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="160" fixed="right" align="center">
            <template slot-scope="scope">
              <el-button
                size="small"
                data-tracker="P11-4"
                type="text"
                @click="handleClickEdit(scope.row, 'detail')"
                v-permission="'waybill_receipt_detail_waybill_id'"
                >详情
              </el-button>
              <el-button
                size="small"
                data-tracker="P11-5"
                type="text"
                v-if="tabIndex === '0'"
                @click="handleClickEdit(scope.row, 'edit')"
                v-permission="'waybill_receipt_update'"
                >编辑</el-button
              >
              <el-button
                v-permission="'abnormal_record_create'"
                type="text"
                size="small"
                data-tracker="P11-13"
                @click="clickabnormalFn(scope.row)"
                >异常操作</el-button
              >
            </template>
          </el-table-column>
        </el-table> -->
      </div>
    </div>
    <StepOperation
      :mode="mode"
      :showDialog="showDialog"
      :key="Math.random()"
      :id="nowId"
      :ids="checkedOrders.map(Number)"
      :step="5"
      @closeDialog="handleCloseDialog"
    ></StepOperation>
    <ImportReceipt
      :drawerReceiptData="drawerReceiptFlagShow"
      @drawerReceiptShow="drawerReceiptFlagShowFn"
    >
    </ImportReceipt>
  </div>
</template>

<script>
import TableHeader from "@/page/orderform/components/TableHeader/tableheader.vue";
import {
  ReceiptListFn,
  ReceiptWithStatusList,
  reqWebsiteList,
  ReceiptDetailFn,
  ReceiptSign,
  ReceiptSignCancel,
  ReceiptDelete,
  ReceiptFinishList,
  ReceiptUnsignList,
  ReceiptSignList,
  WaybillReceiptStayExport,
  WaybillReceiptExport,
} from "@/api/waybill";
import FinishTime from "./components/finishTime.vue";
import StepOperation from "./components/stepOperation.vue";
import ImportReceipt from "../../components/waybillPop/ImportReceipt.vue";
import WaybillSearchHead from "./components/waybillSearchHead.vue";
import SettinUp from "@/page/orderform/components/settingUp/settingUp.vue";
import { organizationBox } from "@/api/organization";
import { statusArr } from "./constants/index.js";
import AbnormalModal from "./components/abnormalModal.vue";
import { sendClickTracker } from "@/utils/tracker";

export default {
  name: "receiptlistpage",
  components: {
    StepOperation,
    ImportReceipt,
    WaybillSearchHead,
    TableHeader,
    SettinUp,
  },
  props: [],
  data() {
    return {
      paginations: {
        pageIndex: 1, // 当前位于哪页
        pageSize: 20, // 1页显示多少条
        pageSizes: [10, 20, 50, 100], //每页显示多少条
        total: 200,
        layout: "total, sizes, prev, pager, next, jumper", // 翻页属性
      },
      tabIndex: "3",
      searchParams: {
        from_network_id: "",
        to_network_id: "",
      },
      orders: [],
      receiptList: [],
      receiptData: [],
      showDialog: false,
      mode: "",
      checkedOrders: [],
      nowId: "",
      drawerReceiptFlagShow: false,
      orderSearch: {},
      organizationBoxData: [],

      propsBranchType: {
        emitPath: false,
        checkStrictly: true,
        value: "id",
        label: "branch_name",
        children: "next_level_data",
      },
      statusArr: statusArr,
      nums: [],
      backCalulte: [
        {
          id: "1",
          name: "未签收",
        },
        {
          id: "2",
          name: "已签收",
        },
      ],
      isLoading: false,
      header_data_list: [],
      propMap: {},
      obj_list: {},
      HeaderData: [],
      orders_list: [],
      header_data_list_two: [],
      propMap_two: {},
      obj_list_two: {},
      HeaderData_two: [],
      orders_list_two: [],
      operation_type: "1",
      create_time: {
        start_time: 1664553600000,
        end_time: new Date().getTime(),
      },
    };
  },
  mounted() {
    // this.getReceiptList();
    this.organizationBoxFn();
    if (this.$route.query.type == 3) {
      this.tabIndex = "3";
      // this.$refs.WaybillSearchHead.handleSearch();
      this.getReceiptList();
    } else if (this.$route.query.type == 1) {
      this.tabIndex = "1";
      this.getReceiptList();
    } else {
      // this.$refs.WaybillSearchHead.handleSearch();
      this.getReceiptList();
    }
  },
  watch: {
    $route: {
      handler(newV, oldV) {
        if (this.$route.query.type == 3) {
          this.tabIndex = "3";
          // this.$refs.WaybillSearchHead.handleSearch();
          this.getReceiptList();
        } else if (this.$route.query.type == 1) {
          this.tabIndex = "1";
          this.getReceiptList();
        } else if (this.$route.query.type == 2) {
          this.tabIndex = "2";
          this.getReceiptList();
        } else if (this.$route.query.type == 0) {
          this.tabIndex = "0";
          this.getReceiptList();
        }
        // console.log(this.$route.query.type, "this.$route.query.type");
      },
      immediate: true,
      deep: true,
    },
  },
  methods: {
    organizationBoxFn() {
      let data = {
        show_employee: false, // 是否展示员工信息
        not_show_first_branch: 1,
      };
      organizationBox(data).then((res) => {
        if (res.code === 10000) {
          this.organizationBoxData = res.data;
        }
      });
    },
    async handleExport() {
      this.isLoading = true;
      let res;

      if (this.tabIndex === "3") {
        const params = this.getStaySearchParams();
        this.derive_list = this.getStaySearchParams();
        res = await WaybillReceiptStayExport({
          ...this.derive_list,
          ids: (this.checkedOrders || []).map(Number),
        });
      } else {
        const params1 = this.getSearchParams();
        res = await WaybillReceiptExport({
          status: this.tabIndex,
          ...this.obj_list_two,
          ids: (this.checkedOrders || []).map(Number),
        });
      }
      if (res.code === 10000) {
        this.reqUrl = "https://" + res.data.loaded_url;
        window.open(this.reqUrl);
        this.isLoading = false;
      }
      sendClickTracker("P11-11");
    },
    handleReceiptSearch(params) {
      // console.log(params, "params");
      this.orderSearch = params;
      this.paginations.pageIndex = 1;
      this.getReceiptList();
    },
    // 重置
    handleReceiptReset(params) {
      // console.log(params, "params");
      this.orderSearch = params;
      this.paginations.pageIndex = 1;
      this.getReceiptList();
    },
    handleWaybillMessage(val) {
      const Fn = ["drawerReceipt"][val];
      this[Fn] && this[Fn]();
      if (val == "4") {
        this.drawerReceipt();
        sendClickTracker("P11-10");
      }
    },
    //异常操作
    clickabnormalFn(valData) {
      const { waybill_id, id } = valData;
      this.$msgbox({
        title: "提交异常",
        message: (
          <AbnormalModal
            key={Math.random()}
            step={5}
            waybillIds={[waybill_id].map(String)}
            nodeId={id + ""}
            style="width:600px"
          ></AbnormalModal>
        ),
        customClass: "temperature_msg",
        showConfirmButton: false,
        showCancelButton: false,
        closeOnClickModal: false,
        showClose: true,
      });
    },
    //回单费用修改导入
    drawerReceipt() {
      this.drawerReceiptFlagShow = true;
    },
    drawerReceiptFlagShowFn(data) {
      this.drawerReceiptFlagShow = data;
    },
    async handleJump(id) {
      let text = this.$router.resolve({
        name: "waybillDetail",
        query: { id, activeName: "1" },
      });
      window.open(text.href, "_blank");
    },
    handleTabClick(tab) {
      this.paginations.pageSize = 20;
      this.paginations.pageIndex = 1;
      this.searchParams = {};
      this.handleReset();
      this.getReceiptList();
    },
    handleSelectionChange(val) {
      this.checkedOrders = val.map((item) => item.id);
    },
    handleCloseDialog(isUpdate = true) {
      this.showDialog = false;
      isUpdate && this.getReceiptList();
    },
    //回单创建
    clickAddPropFn() {
      // this.$router.push({ name: "addReceipt" });
      if (this.checkedOrders.length === 0) {
        this.$message({
          type: "warning",
          message: "请选中运单后进行操作",
        });
        return;
      }
      this.mode = "add";
      this.showDialog = true;
    },
    handleClickOper(type) {
      if (this.checkedOrders.length === 0) {
        this.$message({
          type: "warning",
          message: "请选中运单后进行操作",
        });
        return;
      }
      if (type === "FINISH") {
        const title = "签收";
        this.$msgbox({
          message: (
            <FinishTime
              title={title}
              key={Date.now()}
              hanldeOk={this.handleFinish}
            ></FinishTime>
          ),
          customClass: "temperature_msg",
          showConfirmButton: false,
          showCancelButton: false,
          showClose: true,
          title,
        });
      } else if (type === "CANCEL") {
        ReceiptSignCancel({
          id: this.checkedOrders.map(Number),
          sign_id: this.$store.state.user.user_id + "",
          sign_name: this.$store.state.user.nickname,
        }).then((res) => {
          if (res.code === 10000) {
            this.$message({
              message: "回单取消签收完成",
              type: "success",
            });
            this.getReceiptList();
          }
        });
      } else if (type === "DELETE") {
        ReceiptDelete({
          ids: this.checkedOrders.map(Number),
        }).then((res) => {
          if (res.code === 10000) {
            this.$message({
              message: "取消回单完成",
              type: "success",
            });
            this.getReceiptList();
          }
        });
      }
    },
    handleFinish(time) {
      ReceiptSign({
        id: this.checkedOrders.map(Number),
        sign_time: time,
        sign_id: this.$store.state.user.user_id + "",
        sign_name: this.$store.state.user.nickname,
      }).then((res) => {
        if (res.code === 10000) {
          this.$message({
            message: "回单签收完成",
            type: "success",
          });
          this.getReceiptList();
        }
      });
    },
    handleClickEdit({ id, status }, mode) {
      // if (mode === "edit" && status === "1") {
      //   this.$message({
      //     message: "回单待回单，不能修改！",
      //     type: "warning",
      //   });
      //   return;
      // }
      this.nowId = id;
      this.mode = mode;
      this.showDialog = true;
    },
    handleSizeChange(val) {
      this.paginations.pageSize = val;
      this.getReceiptList();
    },
    handleCurrentChange(val) {
      this.paginations.pageIndex = val;
      this.getReceiptList();
    },
    handleSearch() {
      this.paginations.pageIndex = 1;
      this.getReceiptList();
    },
    handleReset() {
      this.$refs.TableHeaderList.childMethod();
      this.paginations.pageIndex = 1;
      this.getReceiptList();
    },
    getStaySearchParams() {
      return {
        page: this.paginations.pageIndex,
        page_size: this.paginations.pageSize,
        header_id: 1 + "",
        ...this.obj_list,
        create_time: {
          start_time: (this.create_time.start_time + "").slice(0, 10),
          end_time: (this.create_time.end_time + "").slice(0, 10),
        },
      };
    },
    getSearchParams() {
      return {
        page: this.paginations.pageIndex,
        page_size: this.paginations.pageSize,
        header_id: 4 + "",
        ...this.obj_list_two,
        // // status: this.tabIndex,
        // ...this.searchParams,
        // from_network_id:
        //   this.searchParams.from_network_id &&
        //   this.searchParams.from_network_id + "",
        // to_network_id:
        //   this.searchParams.to_network_id &&
        //   this.searchParams.to_network_id + "",
      };
    },
    getReceiptList() {
      // 0 已回单 1 配送完成  2 待回单 3 已签收
      if (this.tabIndex === "3") {
        const params = this.getStaySearchParams();
        ReceiptListFn(params).then((res) => {
          this.orders_list = res.data.data == null ? [] : res.data.data;
          this.orders_list.unshift({});
          this.header_data_list = this.orders_list;
          this.HeaderData = res.data.item_list;
          this.Fntransformation(this.HeaderData);
          this.paginations.total = res.data.total;
          this.nums[this.tabIndex] = res.data.total;
          // this.$refs.multipleTable.clearSelection();
        });
      } else {
        const Fns = [ReceiptFinishList, ReceiptUnsignList, ReceiptSignList];
        const fn = Fns[this.tabIndex];
        const params1 = this.getSearchParams();
        fn &&
          fn(params1).then((res) => {
            this.orders_list_two = res.data.list == null ? [] : res.data.list;
            this.orders_list_two.unshift({});
            this.header_data_list_two = this.orders_list_two;
            this.HeaderData_two = res.data.item_list;
            this.Fntransformation_two(this.HeaderData_two);
            this.paginations.total = res.data.total;
            this.nums[this.tabIndex] = res.data.total;
          });
      }
    },
    objheader(obj) {
      if (this.tabIndex == "3") {
        var data = {
          header_id: 1 + "",
          ...obj,
        };
        this.obj_list = obj;
        this.derive_list = obj;
        ReceiptListFn(data).then((res) => {
          // this.header_data_list = res.data.list
          if (res.code === 10000 && res.data.data !== null) {
            this.orders_list = res.data.data == null ? [] : res.data.data;
            this.orders_list.unshift({});
            this.header_data_list = this.orders_list;
            this.paginations.total = res.data.total;
            this.nums[this.tabIndex] = res.data.total;
            this.paginations.pageSize = res.data.page_size;
            this.paginations.pageIndex = res.data.page;
            //  this.$emit("valueChanged", res.data.total);
          } else {
            this.header_data_list = [{}];
            this.nums[this.tabIndex] = 0;
            this.paginations.total = res.data.total;
          }
        });
      }
    },
    handleDelete(index, id, type) {
      this.handleJump(id.id);
    },
    handleDeleteType(value) {
      this.checkedOrders = value.map(String);
    },
    // 隐射函数
    Fntransformation(obj) {
      const result = {};
      for (const prop in obj) {
        if (obj.hasOwnProperty(prop)) {
          if (obj[prop].send_name !== "") {
            result[obj[prop].name] = obj[prop].show_name;
          } else {
            result[obj[prop].name] = obj[prop].name;
          }
        }
      }
      this.propMap = result;
    },
    objheader_two(obj) {
      this.orders_list_two = [];
      var data = {
        header_id: 4 + "",
        ...obj,
      };
      this.obj_list_two = obj;
      const Fns = [ReceiptFinishList, ReceiptUnsignList, ReceiptSignList];
      const fn = Fns[this.tabIndex];
      fn &&
        fn(data).then((res) => {
          // this.header_data_list = res.data.list
          if (res.code === 10000 && res.data.list !== null) {
            this.orders_list_two = res.data.list == null ? [] : res.data.list;
            this.orders_list_two.unshift({});
            this.header_data_list_two = this.orders_list_two;
            this.paginations.total = res.data.total;
            this.nums[this.tabIndex] = res.data.total;
            this.paginations.pageSize = res.data.page_size;
            this.paginations.pageIndex = res.data.page;
          } else {
            this.header_data_list_two = [{}];
            this.nums[this.tabIndex] = 0;
            this.paginations.total = res.data.total;
          }
        });
    },
    handleDelete_two(index, id, type) {
      this.handleJump(id);
    },
    handleDeleteType_two(value) {
      this.checkedOrders = value.map(String);
    },
    // 隐射函数
    Fntransformation_two(obj) {
      const result = {};
      for (const prop in obj) {
        if (obj.hasOwnProperty(prop)) {
          if (obj[prop].send_name !== "") {
            result[obj[prop].name] = obj[prop].show_name;
          } else {
            result[obj[prop].name] = obj[prop].name;
          }
        }
      }
      this.propMap_two = result;
    },
    handleClickDetail_three(val) {
      this.handleClickEdit(val, "detail");
    },
    handleClickEdit_three(val) {
      // // console.log(val,"fjalksdjflakjdsf")
      this.handleClickEdit(val, "edit");
    },
    clickabnormalFn_three(val) {
      this.clickabnormalFn(val);
    },
    objSettinUp() {
      this.getReceiptList();
    },
    handleJumpway(scope, index) {
      this.handleJump_list(scope, index);
    },
    handleJump_list(scope, index) {
      const waybill_id_list = scope.row.waybill_list || [];

      const id = waybill_id_list[index].waybill_id;

      let text = this.$router.resolve({
        name: "waybillDetail",
        query: { id, activeName: "1" },
      });
      window.open(text.href, "_blank");
    },
  },
};
</script>
<style lang="scss" scoped>
// /deep/ .el-tabs__nav-wrap {
//   left: -154px;
// }
.allOrderContainer {
  padding: 10px 15px;

  background-color: #fff;
  .content-wrapper {
    // background-color: #fff;
    // padding: 10px;
  }

  .actions {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    width: 100%;
    background-color: #fff;
    .el-button + .el-dropdown,
    .el-dropdown + .el-button {
      margin-left: 10px;
    }
  }

  .content {
    // padding: 0 0 0 10px;
    background-color: #fff;
  }

  .orderHeader {
    background-color: #fff;

    .orderSearch {
      // padding-left: 10px;

      form {
        ::v-deep .el-form-item__label {
          font-size: 14px;
        }

        .el-textarea {
          width: 135px;
        }
      }
    }
  }
}

.tab.el-tabs--border-card {
  border: none;
  box-shadow: none;

  .el-tabs__content {
    padding: 0;
    height: 40px;
  }
}

/deep/.tab.el-tabs--border-card > .el-tabs__content {
  padding: 0px;
}

/deep/.badge_item .el-badge__content {
  height: 15px;
  line-height: 15px;
}

/deep/.badge_item .el-badge__content.is-fixed {
  top: 6px;
}
</style>
